
<div style="width: 100%;display: flex;flex-direction: column">
    <iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe>
    <table class="table table-dark table-striped">
        <thead>
          <tr>
            <th>name</th>
            <th>subject</th>
            <th>score</th>
              <th>amend</th>
          </tr>
        </thead>
        <tbody>
          {% for i in query %}
              <tr>



                    <td>{{ i.student.name }}</td>
                    <td>{{ i.exaln.get_examination_type_display() }}</td>
                    <td>
                        <form action="{{ url('login@testScore') }}" id="form-{{ i.id }}" target="nm_iframe" method="post" style="display: flex;flex-direction: row">
                            {{ csrf_input }}
                            <input type="hidden" value="{{ i.id }}" name="id">
                            <input type="number" name="score" style="flex: 1" placeholder="score">
                            <input type="text" name="reason_for_failure" style="flex: 1" placeholder="reason for failure">
                        </form>
                  </td>
                    <td><button type="submit"  class="btn btn-success btn-sm" data-id="{{ i.id }}">amend</button></td>

              </tr>
            {% endfor %}
        </tbody>
    </table>
    <hr>
    <table class="table table-dark table-striped">
        <thead>
          <tr>
            <th>name</th>
            <th>subject</th>
            <th>score</th>
            <th>reason for failure</th>
          </tr>
        </thead>
        <tbody>
          {% for i in query2 %}
              <tr>



                    <td>{{ i.student.name }}</td>
                    <td>{{ i.exaln.get_examination_type_display() }}</td>
                    <td>{{ i.score }}</td>
                    <td>{{ i.reason_for_failure }}</td>

              </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
<script>
    $('body').on('click','button[type="submit"]',function(){

        var tag = $(this)

        $.post(
            '/root/testScore',
            {
                csrfmiddlewaretoken:$("#form-"+tag.attr('data-id')).find('input[name="csrfmiddlewaretoken"]').val(),
                id:$("#form-"+tag.attr('data-id')).find('input[name="id"]').val(),
                score:$("#form-"+tag.attr('data-id')).find('input[name="score"]').val(),
                reason_for_failure:$("#form-"+tag.attr('data-id')).find('input[name="reason_for_failure"]').val(),
            },
            function (data) {
                alert(data)
            }
        )
    }

)
</script>

